package com.lyr.swagger3test.controller;

import com.lyr.swagger3test.entiry.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/users")
@Tag(name = "用户管理", description = "用户相关的CRUD操作")
public class UserController {

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取用户", description = "通过用户ID查询用户详情")
    @ApiResponse(responseCode = "200", description = "查询成功",
            content = @Content(schema = @Schema(implementation = User.class)))
    @ApiResponse(responseCode = "404", description = "用户不存在")
    public User getUserById(
            @Parameter(description = "用户ID", required = true)
            @PathVariable Long id) {
        // 业务逻辑
        return new User(id, "张三", 25);
    }

    @PostMapping
    @Operation(summary = "创建用户", description = "添加新用户到系统")
    public User createUser(
            @Parameter(description = "用户信息", required = true)
            @RequestBody User user) {
        // 业务逻辑
        return user;
    }
}